<link href='styles/set.css' rel='stylesheet' />

<section class="content-header">
  <h1>
    集合
    <small>Set panel</small>
  </h1>
  <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-database"></i> 主页</a></li>
    <li class="active">集合</li>
  </ol>
</section>

<section class="content" ng-controller="setCtrl">
  <div class="row">
    <section class="col-lg-12 connectedSortable">
      <div class="box box-default">
        <div class="box-header with-border">
          <h3 class="box-title">编辑集合</h3>
        </div>
        <div class="box-body">
          <ul class="treeview-menu-overwrite">
            <li class='treeview recursion' >
              <a href="javascript:void(0)" ng-click='choose(set)' ng-class='{true:"selected", false:"unselected"}[set==current]'>
                <span><i class="fa fa-folder-open-o"></i> <input type="text" class="form-control custom" ng-model="set.name" /></span>
                <!-- <span class='pull-right' style='margin-right:15px'><i class="fa fa-angle-down"></i></span> -->
                <span class='btn-circle btn-circle-danger pull-right' style='margin-right:15px;visibility:hidden'><i class="fa fa-minus-circle"></i></span>
                <span class='btn-circle btn-circle-info pull-right' style='margin-right:5px' ng-click='add(set, $event)'><i class="fa fa-plus-circle"></i></span>

              </a>
              <!-- 树状列表 -->
              <div class="recursion">
                <ul class="treeview-menu-overwrite" ng-include="'recursion'" ng-init='rules=set.children;parent=set'>
                </ul>
              </div>
            </li>
          </ul>

          <!-- <ul class="" -->
          <!-- <button ng-click='add(set, $event)'>add</button> -->
          <div class="box-footer text-center" style='margin-top:25px'>
            <!-- <button class="btn btn-default btn-xs">保存结构</button> -->
            <button class="btn btn-info" style='margin-right:10px' ng-click="save(set)">
              <i class="fa fa-save"></i> 保存</button>
          </div>
        </div>
      </div>
    </section>
  </div>
</section>

<!-- 递归模板 -->
<script id="recursion" type="text/ng-template">
  <li class="treeview" ng-repeat="rule in rules">
    <a href="javascript:void(0)" ng-click='choose(rule)' ng-class='{true:"selected", false:""}[rule==current]'>
      <span ><i class="fa fa-folder-open-o" ng-if='rule.children.length'></i>
      <i class="fa fa-file-text-o" ng-if='!rule.children.length'></i> <input type="text" class="form-control custom" ng-model="rule.name" /></span>
      <span class='btn-circle btn-circle-danger pull-right' style='margin-right:15px'><i class="fa fa-minus-circle" ng-click='remove(parent, $index)'></i></span>
      <span class='btn-circle btn-circle-info pull-right' style='margin-right:5px'><i class="fa fa-plus-circle" ng-click='add(rule, $event)'></i></span>
    </a>
    <ul class="treeview-menu-overwrite" ng-if="rule.children.length" ng-include="'recursion'" ng-init="rules=rule.children;parent=rule">
    </ul>
  </li>
</script>
